{php include wl_template('common/header');}
<ul class="nav nav-tabs">
    <li><a href="{php echo web_url('live/goods/goodsList')}">商品列表</a></li>
    <li class="active"><a href="{php echo web_url('live/goods/add')}">发布商品</a></li>
</ul>
<div class="app-content">
    <div class="app-form">
        <div class="panel panel-default">
            <form class="form-horizontal form-validate" method="post">
                <div class="form-group" id="goods">
                    <label class="col-sm-2 control-label must">选择商品</label>
                    <div class="col-sm-9 is_judge" is_judge="false">
                        {php echo tpl_select_goods([]);}
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">商品图片</label>
                    <div class="col-sm-9">
                        {php echo attachment_select('data[coverImgUrl]', '');}
                        <span class="help-block">图片尺寸最大300像素*300像素，如果不传图片则默认使用当前商品logo图片</span>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-2 control-label must ">商品名称</div>
                    <div class="col-sm-9">
                        <input class="form-control" type="text" minlength="3" maxlength="14" name="data[name]"/>
                        <div class="help-block">最少3汉字6字母;最大14个汉字28字母。不填则默认使用商品当前名称，超出长度则截取前14位。</div>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">价格类型</label>
                    <div class="col-sm-9">
                        <label class="radio-inline">
                            <input type="radio" name="data[priceType]" value="1" checked="checked"> 一口价
                        </label>
                        <label class="radio-inline">
                            <input type="radio" name="data[priceType]" value="2"> 价格区间
                        </label>
                        <label class="radio-inline">
                            <input type="radio" name="data[priceType]" value="3"> 折扣价
                        </label>
                        <div class="help-block">默认使用一口价类型。价格为当前商品价格</div>
                    </div>
                </div>
                <!-- 价格类型 -->
                <div class="form-group">
                    <div class="col-sm-2 control-label must" id="price">售价</div>
                    <div class="col-sm-9">
                        <input class="form-control" type="number" name="data[price]"/>
                    </div>
                </div>
                <div class="form-group hide">
                    <div class="col-sm-2 control-label must" id="price2"></div>
                    <div class="col-sm-9">
                        <input class="form-control" type="number" name="data[price2]"/>
                    </div>
                </div>
                <!--添加按钮-->
                <div class="form-group">
                    <label class="col-sm-2 control-label"></label>
                    <div class="col-sm-9">
                        <input type="hidden" name="id" value="{$info['id']}" />
                        <input type="hidden" name="token" value="{$_W['token']}" />
                        <input type="submit" name="submit" value="提交" class="btn btn-primary col-sm-1 min-width" />
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
<script>
    /**
     * 更换价格类型
     */
    $("[name='data[priceType]']").on('change',function () {
        //基本参数信息获取
        let _this = $(this),
            _val  = _this.val();
        //根据价格类型进行对应的操作
        if(_val == 1){
            //标题信息替换
            $("#price").html('售价');
            $("#price2").html('');
            //隐藏价格二
            $("#price2").parent(".form-group").addClass('hide');
        }else if(_val == 2){
            //标题信息替换
            $("#price").html('最低价');
            $("#price2").html('最高价');
            //显示价格二
            $("#price2").parent(".form-group").removeClass('hide');
        }else if(_val == 3){
            //标题信息替换
            $("#price").html('原价');
            $("#price2").html('现价');
            //显示价格二
            $("#price2").parent(".form-group").removeClass('hide');
        }
    });
</script>
{php include wl_template('common/footer');}
